package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.entity.LogisticsPost;
import com.yidu.logisticssystem.dao.LogisticsPostDao;
import com.yidu.logisticssystem.entity.vo.LogisticsModVo;
import com.yidu.logisticssystem.entity.vo.LogisticsPostVo;
import com.yidu.logisticssystem.service.LogisticsPostService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 职位(LogisticsPost)表服务实现类
 *
 * @author makejava
 * @since 2021-03-08 16:46:52
 */
@Service("logisticsPostService")
public class LogisticsPostServiceImpl implements LogisticsPostService {
    @Resource
    private LogisticsPostDao logisticsPostDao;

    /**
     * 通过ID查询单条数据
     *
     * @param postId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsPost queryById(Integer postId) {
        return this.logisticsPostDao.queryById(postId);
    }

    /**
     * 通过ID查询模块数据
     *
     * @param postId 主键
     * @return 实例对象
     */
    @Override
    public List<LogisticsModVo> queryBymodId(Integer postId) {
        return this.logisticsPostDao.queryBymodId(postId);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @Override
    public List<LogisticsPost> queryAllByLimit() {
        return this.logisticsPostDao.queryAllByLimit();
    }

    /**
     * 新增数据
     *
     * @param logisticsPost 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsPost insert(LogisticsPost logisticsPost) {
        this.logisticsPostDao.insert(logisticsPost);
        return logisticsPost;
    }

    /**
     * 修改数据
     *
     * @param logisticsPost 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsPost update(LogisticsPost logisticsPost) {
        this.logisticsPostDao.update(logisticsPost);
        return this.queryById(logisticsPost.getPostId());
    }

    /**
     * 通过主键删除数据
     *
     * @param postId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer postId) {
        return this.logisticsPostDao.deleteById(postId) > 0;
    }
    /**
     * 通过部门删除数据
     *
     * @param sectionId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteBysectionId(Integer sectionId) {
        return this.logisticsPostDao.deleteBysectionId(sectionId) > 0;
    }

    /**
     * 查询职位
     * @param sectionId
     * @return
     */
    @Override
    public List<LogisticsPost> select(Integer sectionId) {
        return this.logisticsPostDao.select(sectionId);
    }
}
